<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<ul id="events"></ul>
<script type="application/javascript">
        function add(message) {
            const el = document.createElement("li");
            el.innerHTML = message;
            document.getElementById("events").appendChild(el);
        }
        var eventSource = new EventSource("/temperature-stream");
        eventSource.onmessage=e=>{
            const t = JSON.parse(e.data);
            const fixed = Number(t.value).toFixed(2);
            add('Temperature: '+fixed+' C');
        }
        eventSource.onopen=e=>add('Connection opend');
        eventSource.onerror=e=>add('Connection closed');
</script>
</body>
</html>